<form id="add-form" class="form-horizontal form-error" role="form" data-toggle="validator" method="POST" action="">
    {:token()}
   
    <div class="form-group">
        <label for="c-title" class="control-label col-xs-12 col-sm-2">{:__('规则名称')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-title" data-rule="required" placeholder="规则名最多60个字" class="form-control" name="row[name]" type="text" value="{$row['name']}">
        </div>
        <div style="clear: both;"></div>
    </div>
    <div id="_keywordItem">
        <?php foreach($keywords as $k=>$keyword):?>
        <div class="form-group" style="margin-bottom: 15px;">
            <label for="c-keyword" class="control-label col-xs-12 col-sm-2"><?php if($k == 0):?>{:__('关键词')}:<?php endif; ?></label>
            <div class="col-xs-12 col-sm-8">
                
                <input placeholder="" class="form-control" name="mate[{$k}][keyword]" type="text" value="{$keyword}">
                
            </div>
            <?php if($k == 0):?>
            <a href="javascript:;" class="btn btn-primary keyword-push"><i class="fa fa-plus"></i> </a>
            <?php else:?>
            <a href="javascript:;" class="btn btn-danger keyword-remove"><i class="fa fa-minus"></i> </a>
            <?php endif; ?>
        </div>
        <div style="clear: both;"></div>
        <?php endforeach;?>
    </div>
    
     <div class="form-group" style="margin-bottom: 15px;">
        <label for="c-keyword" class="control-label col-xs-12 col-sm-2">{:__('回复内容')}:</label>
        <div class="col-xs-12 col-sm-8">
            <p style="padding-top:7px;">
                <input type="radio" name="row[type]" value="text" <?php if($row['type'] == 'text'){echo "checked='checked'";}?> > 文字　
                <input type="radio" name="row[type]" value="image" <?php if($row['type'] == 'image'){echo "checked='checked'";}?> > 图片　
                <input type="radio" name="row[type]" value="mpnews" <?php if($row['type'] == 'mpnews'){echo "checked='checked'";}?> data-href="{:url('material/item')}"> 图文
            </p>
            <!--文字内容-->
            <div class="_content content-text" style="display: {$t['text']}">
                <textarea id="c-content" class="form-control simple-editor" name="row[content]">{:isset($row['content']) ? $row['content'] : ''}</textarea>
            </div>
            <!--图片内容-->
            <div class="_content content-image" style="display: {$t['image']}">
                <div class="input-group">
                    <input id="c-image" class="form-control" size="35" name="row[image]" type="text" value="{:isset($row['image']) ? $row['image'] : ''}">
                    <input type="hidden" id="_media_id" name="row[media_id]" value="{:isset($row['media_id']) ? $row['media_id'] : ''}" >
                    <div class="input-group-addon no-border no-padding">
                        <span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/jpeg,image/png,image/jpg,image/bmp" data-url="{:url('ajax/wxupload')}" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                        <span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                    </div>
                    <span class="msg-box n-right"></span>
                </div>
                <ul class="row list-inline faupload-preview" id="p-image"></ul>
            </div>
            <!--图文内容-->
            <div class="_content content-material" style="display: {$t['mpnews']}">
                <?php if(isset($material) && !empty($material)):?>
                <div class="material-items">
                    <div class="material-body" style="border:1px solid #ccc;">
                        <input type="hidden" name="row[material_id]" value="{$material['id']}">
                        <div class="material_item item-1 active" data-aid="0" id="appmsg-item-0">
                            <div class="appmsg_thumb _thumb" style="background-image:url('{$material['thumb']|default='/assets/img/circle.png'}');"></div>
                            <div class="appmsg_text _title">{$material['title']|default='我是标题...'}</div>
                        </div>
                        <?php if($material['items']):?>
                        
                        <?php foreach($material['items'] as $k=>$item):?>
                            <div class="material_item item-last" id="appmsg-item-{$k+1}" data-aid="{$k+1}">
                                <div class="item-last-body">
                                    <div class="appmsg-title">
                                        <strong class="_title">{$item['title']}</strong>
                                    </div>
                                    <div class="appmsg_thumb">
                                        <img class="_thumb" src="{$item['thumb']}">
                                    </div>
                                </div>
                                
                            </div>
                        <?php endforeach;?>
                        <?php endif;?>
                    </div>
                </div> 
                <?php endif;?>
            </div>
        </div>
        <div style="clear: both;"></div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-10 text-right">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>

    </div>
</form>
<script type="text/html" id="_keywordTempHtml">
    <div class="form-group" style="margin-bottom: 15px;">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <input placeholder="" class="form-control" name="mate[{_index}][keyword]" type="text" value="">
        </div>
        <a href="javascript:;" class="btn btn-danger keyword-remove"><i class="fa fa-minus"></i> </a>
    </div>
</script>
